package com.sun.controller;

import com.sun.dao.EmployeeDao;
import com.sun.entities.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 类型转换器
 * @author sun
 */
@Controller
public class TypeConversionHandler {

    @Autowired
    private EmployeeDao employeeDao;

    /**
     * // String -> Employee 需要类型转换器帮忙
     * @param employee
     * @return
     */
    @RequestMapping("/empAdd")
    public String empAdd(Employee employee){
        System.out.println("TypeConversionHandler - " + employee);
        employeeDao.save(employee);
        return "redirect:/emps";
    }
}
